package svc

import (
	"go-weixin/app/mqueue/tasks/internal/config"

	"go-weixin/common/chendb"
	"go-weixin/common/chendb/xorms"
	"go-weixin/common/es"

	"github.com/zeromicro/go-queue/dq"
)

type ServiceContext struct {
	Config     config.Config
	ChenDb     *chendb.ChenDb
	DqConsumer dq.Consumer
	Es         *es.Es
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:     c,
		ChenDb:     xorms.NewXormsDb(c.Mysql.Username, c.Mysql.Password, c.Mysql.Host, c.Mysql.Port, c.Mysql.Databases, c.Mysql.Showsql, c.Mysql.Migrate, c.Name),
		DqConsumer: dq.NewConsumer(c.DqConf),
		Es:         es.NewEs(c.EsConf.Host, c.EsConf.Port, c.EsConf.User, c.EsConf.Password),
	}
}
